package com.netease.contract.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.shell.standard.ShellComponent;
import org.springframework.shell.standard.ShellMethod;

import javax.annotation.Resource;

@ShellComponent
@Slf4j
public class ContractService {
    @Resource
    private ContractDownloadService contractDownloadService;

    @ShellMethod("处理固定编号以后的合同文件 参数：<处理月> <处理起始日期> <处理结束日期> <编号>")
    public String contractProcessFromLastId(String monthDate, String startDate, String endDate, Long lastId) {
        try {
            contractDownloadService.process(monthDate, startDate, endDate, lastId);

        } catch (Exception e) {
            log.error("exception", e);
            return "exception";
        }
        return "success";
    }

    @ShellMethod("处理合同文件 参数：<处理月> <处理起始日期> <处理结束日期>")
    public String contractProcess(String monthDate, String startDate, String endDate) {
        try {
            contractDownloadService.process(monthDate, startDate, endDate, null);

        } catch (Exception e) {
            log.error("exception", e);
            return "exception";
        }
        return "success";
    }
}